package com.example.demo.service;

import com.example.demo.module.MyModule;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import javax.annotation.PostConstruct;
import java.util.Map;

@Service
@Slf4j
public class MyService {

    @Autowired
    private MyModule myModule;



    @PostConstruct
    public void init() {
        System.out.println(myModule.attr);


    }

    public static void main(String[] args) {
       /* HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/x-www-form-urlencoded");
        headers.add("Accept","application/json");
        MultiValueMap<String, Object> postParameters = new LinkedMultiValueMap<>();
        postParameters.add("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer");
        postParameters.add("client_id", "d0642ef0-74d2-48ea-9ba0-0dd69512c048");
        postParameters.add("client_secret", "~.U7E5-PLN2S_DAQdB6GxsHdMukz34ka0d");
        postParameters.add("assertion", "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Im5PbzNaRHJPRFhFSzFqS1doWHNsSFJfS1hFZyJ9.eyJhdWQiOiJkMDY0MmVmMC03NGQyLTQ4ZWEtOWJhMC0wZGQ2OTUxMmMwNDgiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vMDcyMDA5OGUtNTg2Ny00ZDdhLTk5ZjgtNzRhZGQ0MzFiYmM3L3YyLjAiLCJpYXQiOjE2MjAzNjQxMzIsIm5iZiI6MTYyMDM2NDEzMiwiZXhwIjoxNjIwMzcxNjMyLCJhaW8iOiJBVFFBeS84VEFBQUFFYmsyZzVtYmxnMGtIN0RSRXp2RUZNbjBqQzYxeEdtY2lXMWIvNGRudGoxcUFDUUV5R0JHVFZmWmR5dWVkQkJ6IiwiYXpwIjoiNWUzY2U2YzAtMmIxZi00Mjg1LThkNGItNzVlZTc4Nzg3MzQ2IiwiYXpwYWNyIjoiMCIsIm5hbWUiOiJyZWYgdGlhbiIsIm9pZCI6IjU4NTg2YjlhLWZkMTktNGJmZC04MzZjLWM4ZGI0MTAyMDYzNSIsInByZWZlcnJlZF91c2VybmFtZSI6InJlZkByZWZ0aWFuLm9ubWljcm9zb2Z0LmNvbSIsInJoIjoiMC5BWEFBamdrZ0IyZFllazJaLUhTdDFERzd4OERtUEY0Zks0VkNqVXQxN25oNGMwWndBSU0uIiwic2NwIjoiYWNjZXNzX2FzX3VzZXIgdGFiIiwic3ViIjoicmdfWkp2eGVBbHlTX1BiZFJkcGNQbDBJNmJxUE5HSzBhZHY1M2xMZlBIayIsInRpZCI6IjA3MjAwOThlLTU4NjctNGQ3YS05OWY4LTc0YWRkNDMxYmJjNyIsInV0aSI6Ii15Y25ZekliNkU2dTBESS0xQkpsQXciLCJ2ZXIiOiIyLjAifQ.YMVnHroSdEn29xxQENFNDcWRlXdhCbhA_cW99RzzSy00wdmHGv5DjyDIaD8-zFjK43NG48oPCWyiY8se7c8FPOHue3z_-6bImHRMnyvEnbeStHSNzYSYsKdjBFgymM8NFI4GLHE-KgT36USAol_5tjFiYKcqX67Sk3ZK5sAAYzn91D-wmu-O4-mrehQBnunyoxtOdmFRHZNNuHfz0S36wszZ_Pi4CX53uJDNMm994-Z3BQyctk4QePT-VfAFyd4GTAlWpf-1IIFoYhcrzUPutkbKw09Bn1EL_6Ces0KpErlSRooNz7_d72UMwPtKGoX1TJ8qtY5IglnaELhwBVsoiA\n");

        postParameters.add("scope", "https://graph.microsoft.com/User.Read");
        postParameters.add("requested_token_use", "on_behalf_of");

        HttpEntity<MultiValueMap<String, Object>> httpEntity =
                new HttpEntity<>(postParameters, headers);
        RestTemplate restTemplate = new RestTemplate();
        Map m = restTemplate.postForObject("https://login.microsoftonline.com/0720098e-5867-4d7a-99f8-74add431bbc7/oauth2/v2.0/token",
                httpEntity, Map.class);

            log.info(m.get("access_token").toString());*/
    }
}
